// export const BASE_URL = 'http://47.95.216.146:8080/supermarket'
export const BASE_URL = 'https://www.wujiaqi.xyz/supermarket'

export const myRequest = (options)=>{
	return new Promise((resolve,reject)=>{
		/* uni.showLoading({
		    title: '加载中'
		}); */
		// console.log('测试')
		uni.request({
			// url:options.url,
			url:BASE_URL+options.url,
			method: options.method || 'GET',
			data: options.data || {},
			success: (res)=>{
				/* if(res.data.status !== 0) {
					return uni.showToast({
						title: '获取数据失败'
					})
				} */
				resolve(res.data)
				uni.hideLoading()
			},
			fail: (err)=>{
				uni.showToast({
					title: '请求接口失败'
				})
				reject(err)
			}
		})
	})
}

export const request = (options)=>{
	return new Promise((resolve,reject)=>{
		
		uni.request({
			// url:options.url,
			url:options.url,
			method: options.method || 'GET',
			data: options.data || {},
			success: (res)=>{
				resolve(res.data)
				uni.hideLoading()
			},
			fail: (err)=>{
				uni.showToast({
					title: '请求接口失败'
				})
				reject(err)
			}
		})
	})
}

export const slice_time=(time_string)=>{
	let Y=time_string.slice(0,4)+'-'
	let M=time_string.slice(4,6)+'-'
	let D=time_string.slice(6,8)+' '
	
	let h=time_string.slice(8,10)+':'
	let m=time_string.slice(10,12)+''
	return(Y+M+D+h+m)
}

export const  timestap_alert=(originaltime)=>{
			  const date = new Date(originaltime)
			  var Y = date.getFullYear() + '-';
			  var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
			  var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
			  var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
			  var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'; //date.getMinutes() + ':';
			  var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
			  return (Y + M + D + h + m + s)
			}